Skip to content

[#635] Dedupe profile page DB queries into single lookup#652

Merged
realproject7 merged 2 commits intomainfrom
task/635-profile-dedup-queries
Mar 30, 2026
Merged

[#635] Dedupe profile page DB queries into single lookup#652
realproject7 merged 2 commits intomainfrom
task/635-profile-dedup-queries

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • lib/actions.ts: Added getFullUserProfile() that fetches getUserFromDB() once and passes the result to getFarcasterProfile() and fetchAgentMetadata(). Both functions now accept an optional dbUser parameter to skip redundant lookups.
  • profile/[address]/page.tsx: Replaced 3 separate useQuery calls with a single getFullUserProfile() call. Reduces 3+ DB round-trips to 1 per profile page load.

Fixes #635
Tracks realproject7/agent-os#315

Test plan

  • Profile page makes 1 DB lookup (not 3+)
  • Farcaster profile and agent metadata still resolve correctly
  • External API fallback still works when DB data is missing
  • Wallet-only profiles (no FID) still work
  • Build passes

🤖 Generated with Claude Code

- Added getFullUserProfile() that fetches getUserFromDB() once and
  passes the result to getFarcasterProfile() and fetchAgentMetadata()
- Both functions now accept optional pre-fetched dbUser parameter
- Profile page uses single useQuery instead of 3 parallel queries
- Reduces 3+ DB round-trips to 1 on every profile page load

Fixes #635

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored Mar 30, 2026 7:35pm

Request Review

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The query-dedup refactor reduces DB reads, but it changes the agent-metadata lookup semantics in a way that can hide cached agent profiles.

Findings

  • [high] getFullUserProfile() passes the generic getUserFromDB() result into fetchAgentMetadata(), replacing the previous agent-specific getAgentUserFromDB() lookup. That can miss cached agent rows for externally registered agent owners when a normal user row is found first.
    • File: lib/actions.ts:102
    • Suggestion: Keep the single shared base lookup for the ordinary profile row, but preserve agent-specific resolution semantics. For example, only reuse the preloaded row when it already has agent_id, or let fetchAgentMetadata() fall back to getAgentUserFromDB(address) when the provided row is null or lacks agent fields.

Decision

Requesting changes because the issue requires agent metadata to keep resolving correctly, and this refactor can regress owner-profile agent detection by short-circuiting the agent-specific DB lookup.

…t_id

Only reuses the preloaded user for agent metadata when it has agent_id.
Otherwise falls back to the agent-specific lookup (getAgentUserFromDB)
which searches agent_wallet and agent_owner columns.

Addresses T2a review feedback on PR #652.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The profile-page dedup refactor now keeps the shared user-row fetch while preserving the original agent-specific lookup semantics when the preloaded row does not already contain agent metadata.

Findings

  • None.

Decision

Approving on code review. The earlier agent-lookup regression is addressed; remaining CI checks are still running, but they do not block the review verdict.

@realproject7 realproject7 merged commit e8dfa8f into main Mar 30, 2026
5 checks passed
@realproject7 realproject7 deleted the task/635-profile-dedup-queries branch March 30, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eliminate duplicate DB queries on profile page

2 participants